package eop.project;

import groovy.util.GroovyTestCase;

class LoadActivityDatabaseTest extends GroovyTestCase {
	void testReadActivity(){
		String txt = '''IDD60156
			  VOLCANIC ASH ADVISORIES FROM DARWIN VAAC - LAST 7 DAYS
			  DARWIN VAAC      16:00 UTC, 27/06/2010
--------------------------------------------------------------------

Received FVAU0295 at 11:24 UTC, 27/06/10 from ADRM
VA ADVISORY
DTG:  20100627/1124Z
VAAC:  Darwin

VOLCANO:  Ulawun  0502-12
PSN:  S0503 E15120
AREA:  New_Britain SW_Pac
SUMMIT ELEV:  2334M

ADVISORY NR:  2010/122
INFO SOURCE:  MTSAT-1R
AVIATION COLOUR CODE:  ORANGE
ERUPTION DETAILS:  VA PLUME/STEAM TO FL120 LAST OBS EXTENDING 35NM
TO W AT 27/0130Z

OBS VA DTG:  27/1115Z
OBS VA CLD:
SFC/FL120 S0520 E15125 - S0445 E15130 - S0420 E15035 -
S0510 E15025 - S0520 E15125 MOV W 10KT

FCST VA CLD +6HR:  27/1715Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125
FCST VA CLD +12HR:  27/2315Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125
FCST VA CLD +18HR:  28/0515Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125

RMK:  VA NOT IDENTIFIABLE ON LATEST SATELLITE IMAGE DUE TO
METEOROLOGICAL CLOUD, BUT STILL EXPECTED IN AREA.  Graphic at
[lower case] http://www.bom.gov.au/info/vaac/advisories.shtml
NXT ADVISORY:  NO LATER THAN 20100627/1715Z

Received FVAU0295 at 05:07 UTC, 27/06/10 from ADRM
VA ADVISORY
DTG:  20100627/0505Z
VAAC:  Darwin

VOLCANO:  Ulawun  0502-12
PSN:  S0503 E15120
AREA:  New_Britain SW_Pac
SUMMIT ELEV:  2334M

ADVISORY NR:  2010/121
INFO SOURCE:  MTSAT-1R
AVIATION COLOUR CODE:  ORANGE
ERUPTION DETAILS:  VA PLUME/STEAM TO FL120 LAST OBS EXTENDING 35NM
TO W AT 27/0130Z

OBS VA DTG:  27/0515Z
OBS VA CLD:
SFC/FL120 S0520 E15125 - S0445 E15130 - S0420 E15035 -
S0510 E15025 - S0520 E15125 MOV W 10KT

FCST VA CLD +6HR:  27/1115Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125
FCST VA CLD +12HR:  27/1715Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125
FCST VA CLD +18HR:  27/2315Z
SFC/FL120 S0520 E15125 - S0510 E15025 - S0420 E15035 -
S0445 E15130 - S0520 E15125

RMK:  VA NOT IDENTIFIABLE ON LATEST SATELLITE IMAGE DUE TO
METEOROLOGICAL CLOUD, BUT STILL EXPECTED IN AREA.  Graphic at
[lower case] http://www.bom.gov.au/info/vaac/advisories.shtml
NXT ADVISORY:  NO LATER THAN 20100627/1115Z
			'''
		
		def dtg = txt =~ /Received.*/
		def vaac = txt =~ /VAAC:.*/
		def volcano = txt =~ /VOLCANO:.*/
		def advisory = txt =~ /ADVISORY NR:.*/
		def source  = txt =~ /INFO SOURCE:.*/
		//def aviation = txt =~ /AVIATION.*/
		def erruption = txt =~ /ERUPTION DETAILS:.*/
		
		int counter = 0
		Map vacList = [:]
		Map volList = [:]
		println "dtg " + dtg.size()
		println "vaac " + vaac.size()
		println "volcano " + volcano.size()
		println "advisory " + advisory.size()
		println "source " + source.size()
		println "erruption " + erruption.size()
		
		dtg.each{
			volList = [:]
			def mat = it.split (" ")
			//println it
			volList["DTG"] = mat[5] + ":" +mat[3]
			//println vaac[counter]
			volList["VAAC"] = vaac[counter] =~ /\s\w+/
			mat = volcano[counter].split("  ")
			volList["VOLCANO-NAME"] = mat[1]
			volList["VOLCANO-REF"] = mat[2]
			mat = advisory[counter].split("  ")
			//println advisory[counter]
			volList["ADVISORY"] = mat[1]
			mat = source[counter] =~ /:(.*)/
			volList["SOURCE"] = mat[0][0].substring(2,mat[0][0].length())
			mat = erruption[counter] =~ /:(.*)/
			volList["ERRUPTION"] = mat[0][0].substring(3,mat[0][0].length())
			vacList["$counter"] = volList
			counter++
		}
	}
	
	void tmp(){
		def mat = "INFO SOURCE: GOES-13. GFS WINDS. SEISMIC" =~ /:(.*)/
		println mat.size()
		println mat[0][0].substring(2,mat[0][0].length())
		mat = "ERUPTION DETAILS:  VA PLUME/STEAM TO FL120 LAST OBS EXTENDING 35NM" =~ /:(.*)/
		println mat.size()
		println mat[0][0].substring(3,mat[0][0].length())
		
		mat = "ADVISORY NR:  2010/122".split("  ")
		println  mat[1]
		mat = "Received FVAU0295 at 11:24 UTC, 27/06/10 from ADRM".split(" ")
		println mat[5] + " " + mat[3]
	 }
}
